home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.4 Applications 1997 August / SGI IRIX 6.4 Applications 1997 August.iso / dist / mmailp.idb / usr / lib / Zmail / samples / zscript / decmm.zsc.z / decmm.zsc
Encoding:
Text File  |  1997-01-22  |  4.1 KB  |  159 lines

  1. # multimedia functions for DEC OSF/1
  2.  
  3. function play_basic_audio () {
  4. #% (fallback help text)
  5. #    play_basic_audio [filename]
  6. # Play MIME-standard basic audio file until it ends or the user
  7. # presses the stop button.
  8. #%
  9.   sh -m "Playing ... click `Stop' to end play." -t 0 "playfile -f$1 -b8 -s8000 -cMono -emu-law > /dev/null"
  10.   if $?child
  11.     set childPID= $child
  12.     sh -m "Stopping play." "kill -INT $childPID"
  13.     sh "kill -INT $childPID"
  14.   endif
  15.   return 0
  16. }
  17.  
  18. function play_dec_audio () {
  19. #% (fallback help text)
  20. #    play_basic_audio [filename]
  21. # Play DEC audio file until it ends or the user presses the stop button.
  22. #%
  23.   sh -m "Playing ... click `Stop' to end play." -t 0 "playfile -f$1 > /dev/null"
  24.   if $?child
  25.     set childPID= $child
  26.     sh -m "Stopping play." "kill -INT $childPID"
  27.     sh "kill -INT $childPID"
  28.   endif
  29.   return 0
  30. }
  31.  
  32. function record_audio () {
  33. #% (fallback help text)
  34. #    record_audio [filename]
  35. # Record MIME-standard basic audio into file until either the user presses 
  36. # the stop button or 5 minutes have elapsed.
  37. #%
  38.   sh -m "Recording ... click `Stop' when done." -t 0 "recordfile -f$1 -t300 -b8 -s8000 -cMono -emu-law > /dev/null"
  39.   if $?child
  40.     set childPID= $child
  41.     sh -m "Stopping recording." "kill -INT $childPID"
  42.     sh "kill -INT $childPID"
  43.   endif
  44.   return 0
  45. }
  46.  
  47. function create_voice_attach() {
  48. #% (fallback help text)
  49. #    create_voice_attach
  50. # Create a temporary file and record audio into it.
  51. #%
  52.   if $?recordCount
  53.       arith recordCount = $recordCount+1
  54.   else
  55.     set recordCount = 0
  56.   endif
  57.   set tmpRecordFile = $tmpdir/zua$$$recordCount.aud
  58.   record_audio $tmpRecordFile
  59.   compcmd attach-file $tmpRecordFile audio/basic
  60.   set junk += "$tmpRecordFile "
  61. }
  62.  
  63. function record_video () {
  64. #% (fallback help text)
  65. #    record_video
  66. # Record DEC-format video into file until the user presses the stop button.
  67. #
  68. # grabbag, a video tool which also records audio, doesn't take a filename as a 
  69. # command-line argument
  70. #%
  71.   sh -m "Recording ... click `Stop' when done." -t 0 "captio -filename $1 > /dev/null"
  72.   if $?child
  73.     sh -m "Stopping recording." "kill -INT $child"
  74.   endif
  75.   return 0
  76. }
  77.  
  78. function play_video () {
  79. #% (fallback help text)
  80. #    play_video [filename]
  81. # Play DEC-format video file until it ends or the user presses the stop button.
  82. # Unfortunately, capt2_out just plays a single frame
  83. #%
  84.   sh -m "Playing ... click `Stop' to end play." -t 0 "capt2_out -filename $1 > /dev/null"
  85.   if $?child
  86.     sh -m "Stopping play." "kill -INT $child"
  87.   endif
  88.   return 0
  89. }
  90.  
  91. function create_video_attach() {
  92. #% (fallback help text)
  93. #    create_video_attach
  94. # Create DEC-format video and attach to the current composition
  95. #%
  96.   record_video $tmpdir/zvid$$
  97.   compcmd attach-file $tmpdir/zvid$$ video/x-riff
  98.   set junk += "$tmpdir/zvid$$ "
  99. }
  100.  
  101. function cleanup() {
  102. #% (fallback help text)
  103. #    cleanup
  104. # Remove temporary files.
  105. #%
  106.   if $?junk
  107.     remove $junk
  108.     unset junk
  109.   endif
  110.   return 0
  111. }
  112.  
  113. button -W Compose Voice create_voice_attach
  114. button -W Compose Video create_video_attach
  115.  
  116. function speak() {
  117. #% (fallback help text)
  118. #    speak
  119. # If text is selected, read it aloud.  Otherwise, announce the sender of 
  120. # the email and read the whole message aloud.
  121. #%
  122.     textedit set-item message-body
  123.     textedit get-selection-position __start __end
  124.     set tmpSpkFile = $tmpdir/zspeak$$
  125.     if $__start == $__end
  126.     sh speak -a "This message is from $[%n].  The subject is: $[%s]."
  127.     write $tmpSpkFile
  128.     else
  129.     textedit text-pipe "tee $tmpdir/zspeak$$"
  130.     endif
  131.     sh -m "Speaking ... click `Stop' to end play." -t 0 "speak $tmpSpkFile > /dev/null"
  132.     if $?child
  133.     sh -m "Stopping play." "kill -INT $child"
  134.     endif
  135.     remove -f $tmpSpkFile
  136.     return 0
  137. }
  138.  
  139. if is_gui
  140.     button -W Message "Speak" speak
  141. endif
  142.  
  143. # This deletes the file before the composition has gone, so it's not too 
  144. # useful.  Even if it did work, it would cause problems when multiple 
  145. # compositions are going.  Sigh.
  146. # interpose -operation send cleanup
  147.  
  148. # Not sure how to get this going on startup.  Calling the function 
  149. # startup_hook doesn't do much.
  150. function say_hello() {
  151.     sh speak -a "Hello.  Welcome to Z Mail!"
  152. }
  153.  
  154. function say_bye() {
  155.     sh speak -a "Thank you for using Z Mail.  Goodbye!"
  156. }
  157. interpose -before quit say_bye
  158.  
  159.